package com.plugin.manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.plugin.core.model.entity.ElderActivityNotice;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 长者活动通知Mapper接口
 * 
 * @author mark
 * @date 2025-07-29
 */
@Mapper
public interface ElderActivityNoticeMapper extends BaseMapper<ElderActivityNotice> {

    /**
     * 查询所有活动列表（仅返回活动名称、开始时间、结束时间）
     * 
     * @return 活动列表
     */
    @Select("SELECT activity_name, start_time, end_time FROM elder_activity_notice " +
            "WHERE del = 0 AND activity_status = 1 " +
            "ORDER BY start_time DESC LIMIT 1")
    List<ElderActivityNotice> selectActivityList();

    /**
     * 查询即将开始的活动（未来7天内）
     * 
     * @return 活动列表
     */
    @Select("SELECT id, activity_name, start_time, end_time, activity_location FROM elder_activity_notice " +
            "WHERE del = 0 AND activity_status = 1 " +
            "AND start_time >= NOW() AND start_time <= DATE_ADD(NOW(), INTERVAL 7 DAY) " +
            "ORDER BY start_time ASC")
    List<ElderActivityNotice> selectUpcomingActivities();
}
